package common_phrase

import (
	database "hft/Database"
	"time"

	"gorm.io/gorm"
)

// 全局常用语设置常用语
type CommonPhrase struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	CreateTime  time.Time      `json:"-" gorm:"autoCreateTime"`
	UpdateTime  time.Time      `json:"-" gorm:"autoUpdateTime"`
	DeletedTime gorm.DeletedAt `json:"-" gorm:"index"`
	CategoryID  int            `json:"category_id"`
	ChatText    string         `json:"chat_text" gorm:"type:varchar(500)"`
}

func (CommonPhrase) TableName() string {
	return database.TableNameFormat("account_chat_mod")
}

type CommonPhraseCate struct {
	ID           uint            `json:"id" gorm:"primaryKey;autoIncrement"`
	CreateTime   time.Time       `json:"-" gorm:"autoCreateTime"`
	UpdateTime   time.Time       `json:"-" gorm:"autoUpdateTime"`
	CategoryName string          `json:"category_name" gorm:"type:char(50)"`
	CategorySort int             `json:"category_sort" gorm:"type:int(10)"`
	CanEdit      bool            `json:"can_edit"`
	Children     []*CommonPhrase `json:"children" gorm:"foreignKey:CategoryID;references:ID;constraint:OnDelete:CASCADE"`
}

func (CommonPhraseCate) TableName() string {
	return database.TableNameFormat("account_chat_mod_category")
}

type CommonPhraseUsual struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	CategoryID  uint           `json:"category_id"`
	ChatText    string         `json:"chat_text" gorm:"type:varchar(500)"`
	AccountID   int            `json:"account_id"`
	CreateTime  time.Time      `json:"-" gorm:"autoCreateTime"`
	UpdateTime  time.Time      `json:"-" gorm:"autoUpdateTime"`
	DeletedTime gorm.DeletedAt `json:"-" gorm:"index"`
}

func (CommonPhraseUsual) TableName() string {
	return database.TableNameFormat("account_chat_mod_usual")
}
